package com.qiyeji.real_estate.ProjectTask;

import com.qiyeji.real_estate.entity.projectPhase;
import com.qiyeji.real_estate.service.ProjectPhaseService;
import com.qiyeji.real_estate.service.ProjectService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class UpdateProjectStateToComplete implements JavaDelegate {

    @Autowired
    ProjectService projectService;

    @Autowired
    ProjectPhaseService projectPhaseService;

    @Override
    public void execute(DelegateExecution execution) throws Exception {

        System.out.println("修改后期阶段状态为完成！");
        projectPhaseService.updateByPrimaryKey(new projectPhase(execution.getBusinessKey(), "后期", "完成"));
        System.out.println("更改项目状态为完成！");
        projectService.updateForComplete(execution.getBusinessKey());

    }
}
